<template>
    <div>
        <el-tabs v-model="activeName" @tab-click="handleClick" style="padding: 11px">
            <el-tab-pane label="保养计划" name="first">
                <el-dialog title="提交保养计划" :visible.sync="is_showAddPlan" width="500">
                    <div>
                        <el-form>
                            <!-- <el-form-item> -->
                            <div>已勾选<span style="color: red">{{selectedPlans.length}}</span>条,总显示:<span style="color: red">{{tableDataScheduleFilter.length}}</span>条</div>
                            <!-- </el-form-item> -->
                            <el-form-item label="未按照规范保养请备注:">
                                <el-input v-model="remark"></el-input>
                            </el-form-item>
                            <el-form-item label="">
                                <el-button type="primary" @click="savePlans">保存</el-button>
                            </el-form-item>
                        </el-form>
                    </div>
                </el-dialog>
                <el-row>
                    <div>下次保养时间：{{nextTimeTips}} <span style="color:red"> （目前存在需要保养的项目，请及时进行保养）</span>
                        <el-button type="primary" @click="addPlans">提交保养记录</el-button>
                        <el-checkbox v-model="checkedNeed" @change="checkNeed">仅显示需要保养</el-checkbox>
                    </div>
                </el-row>
                <el-row>
                    <div style="border: 0.5px solid #DCDFE6;margin-top: 10px;">
                        <!-- <el-button-group>
                            <el-button size="mini" icon="el-icon-plus" style="border: none;" @click="showAddPlan"></el-button> -->
                        <!-- <el-button size="mini" icon="el-icon-edit" style="border: none;"></el-button> -->
                        <!-- <el-popconfirm title="确定删除所选行吗？"> -->
                        <!-- <el-button size="mini" icon="el-icon-delete" style="border: none;" @click="deletePlan"></el-button> -->
                        <!-- </el-popconfirm>
                        </el-button-group> -->
                        <el-table ref="planTable"
                                  @row-click="planRowClick"
                                  :data="tableDataScheduleFilter"
                                  style="width: 100%"
                                  :header-cell-style="{'font-weight':'bold', color:'#2A2A2A'}"
                                  @selection-change="selectPlans" height="788" :row-class-name="tableRowClassName">

                            <el-table-column prop="station" label="工站" width="100"></el-table-column>
                            <el-table-column prop="parts" label="部件" width="180"></el-table-column>
                            <el-table-column prop="content" label="保养内容" ></el-table-column>
                            <el-table-column prop="way" label="保养方法" width="180"></el-table-column>
                            <el-table-column prop="standard" label="保养标准"></el-table-column>
                            <el-table-column prop="period" label="保养周期" width="80"></el-table-column>
                            <el-table-column prop="preDatetime" label="上次保养时间" width="120"></el-table-column>
                            <el-table-column prop="needMaintenance" label="是否需要保养" width="120">
                                <template slot-scope="scope">
                                    <el-tag v-show="scope.row.needMaintenance=='需要'" type="danger">{{scope.row.needMaintenance}}</el-tag>
                                    <el-tag v-show="scope.row.needMaintenance=='不需要'" type="info">{{scope.row.needMaintenance}}</el-tag>
                                </template>
                            </el-table-column>
                            <el-table-column width="140" label="勾选保养项" prop="maintenance_id">
                                <template slot="header">
                                    <el-checkbox v-model="checkedAll" @change="checkAll">
                                        <span style="font-weight: 800">勾选保养项</span>
                                    </el-checkbox>
                                </template>
                                <template slot-scope="scope">
                                <span>
                                    <el-checkbox v-model="scope.row.checked"></el-checkbox>
                                </span>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </el-row>
            </el-tab-pane>
            <el-tab-pane label="保养记录" name="second">
                <el-row>
                    <el-form :model="logSearchForm" :inline="true">
                        <!-- <el-form-item label="模块" >
                        <el-select v-model="logSearchForm.module">
                            <el-option v-for="item in modules" :key="item.module" :label="item.module" :value="item.module">
                            </el-option>
                        </el-select>
                    </el-form-item> -->
                        <el-form-item label="开始时间">
                            <el-date-picker   v-selfdbclick  v-model="logSearchForm.startTime" value-format="yyyy-MM-dd" placeholder="选择日期" :picker-options="pickerOptions">
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item label="结束时间">
                            <el-date-picker   v-selfdbclick  v-model="logSearchForm.endTime" value-format="yyyy-MM-dd" placeholder="选择日期">
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="searchLog">查询</el-button>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="" @click="exportLog">导出</el-button>
                        </el-form-item>
                    </el-form>
                </el-row>
                <el-row>
                    <div style="border: 0.5px solid #DCDFE6">
                        <!-- <el-button-group>
                            <el-button size="mini" icon="el-icon-plus" style="border: none;" @click="showAddLog"></el-button>
                              <el-button size="mini" icon="el-icon-delete" style="border: none;" @click="deleteLog"></el-button>
                        </el-button-group> -->
                        <el-table ref="logTable" :data="tableDataLog" style="width: 100%" :header-cell-style="{'font-weight':'bold', color:'#2A2A2A'}" highlight-current-row max-height="808">
                            <el-table-column prop="content" label="保养结果" width="180"></el-table-column>
                            <el-table-column prop="dateTime" label="保养时间" width="100"></el-table-column>
                            <el-table-column prop="parts" label="部件" ></el-table-column>
                            <el-table-column prop="operateUser" label="操作人" width="80"></el-table-column>

                        </el-table>
                    </div>
                </el-row>
            </el-tab-pane>

        </el-tabs>

        <el-dialog title="添加保养计划" :visible.sync="is_showAddPlan1" width="500" :before-close="handleClose">
            <div style="overflow-y: auto;height: 560px;">
                <el-form :model="addPlanForm" class="demo-form-inline" :inline="true" label-position="left">
                    <!-- <el-form-item label="保养内容" label-width="100px">
                        <el-input v-model="addPlanForm.label" placeholder="" style="width:240px"></el-input>
                    </el-form-item> -->
                    <el-form-item label="类型" label-width="100px">
                        <el-input v-model="addPlanForm.type" placeholder="" style="width:220px"></el-input>
                    </el-form-item>
                    <el-form-item label="计划时间" label-width="100px">
                        <el-date-picker   v-selfdbclick  v-model="addPlanForm.dateTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="下次保养时间" label-width="100px">
                        <el-date-picker   v-selfdbclick  v-model="addPlanForm.nextTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="操作" label-width="100px">
                        <el-input v-model="addPlanForm.operation" placeholder="" style="width:220px"></el-input>
                    </el-form-item>
                    <el-form-item label="模块" label-width="100px">
                        <el-select style="width: 220px" v-model="selectedModule" @change="changeModule">
                            <el-option v-for="item in modules" :label="item.module" :value="item.module" :key="item.module"></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
                <el-row>
                    <span> 选择部件列表(单击选中一行)</span>
                    <el-table :data="okNgData" ref="addTable" @row-click="selectOkNg" highlight-current-row>
                        <el-table-column prop="parts" label="部件"></el-table-column>
                        <el-table-column prop="way" label="保养方法"></el-table-column>
                        <el-table-column prop="standard" label="保养标准"></el-table-column>
                        <el-table-column prop="info" label="保养内容" width="200"></el-table-column>
                        <el-table-column prop="period" label="保养周期"></el-table-column>
                    </el-table>
                </el-row>
            </div>
            <span slot="footer" class="dialog-footer">
            <!-- <el-button @click="is_addShow = false">取 消</el-button> -->
            <el-button type="primary" @click="addSavePlan">确 定</el-button>
        </span>
        </el-dialog>
        <el-dialog title="添加保养记录" :visible.sync="is_showAddLog" width="600" :before-close="handleClose">
            <div style="overflow-y: auto;height: 560px;">
                <el-form :model="addPlanForm" class="demo-form-inline" label-position="left">
                    <el-form-item label="模块" label-width="100px">
                        <el-select v-model="selectedmodule" placeholder="请选择" @change="changemodule">
                            <el-option v-for="item in adddata" :key="item.module" :label="item.module" :value="item.module">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!-- <el-form-item label="部件" label-width="100px">
                        <el-select v-model="selectedParts" placeholder="请选择" @change="changeParts">
                            <el-option v-for="item in optionsParts" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="保养内容" label-width="100px">
                        <el-select v-model="selectedContent" placeholder="请选择" >
                            <el-option v-for="item in optionsContent" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item> -->

                </el-form>
                <el-row>
                    <span> 选择部件列表(单击选中一行)</span>
                    <el-table :data="addLogTableData" ref="addTableLog" @row-click="selectLogTable" highlight-current-row>
                        <!-- @selection-change="selectOkNg" -->
                        <el-table-column prop="parts" label="部件"></el-table-column>
                        <el-table-column prop="way" label="保养方法"></el-table-column>
                        <el-table-column prop="standard" label="保养标准"></el-table-column>
                        <el-table-column prop="content" label="保养内容" width="200"></el-table-column>
                        <el-table-column prop="period" label="保养周期"></el-table-column>
                    </el-table>
                </el-row>
            </div>
            <span slot="footer" class="dialog-footer">
            <!-- <el-button @click="is_addShow = false">取 消</el-button> -->
            <el-button type="primary" @click="addSaveLog">确 定</el-button>
        </span>
        </el-dialog>
        <!-- <div style="padding-left: 14px;" v-show="userStoreLimits.testuser=='wtc'">test-user</div> -->
    </div>
</template>

<script>
import qwebchannel from '../../qt5.15webchannel.js';
import { mapState } from 'vuex';
import { formatCurrentTime } from '../../utils/tools.js';

export default {
    computed: {
        ...mapState(['userStoreLimits', 'userInfoStore']),

    },
    data() {
        return {
            pickerOptions: {
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        picker.$emit('pick', new Date());
                    }
                }, {
                    text: '昨天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', date);
                    }
                }, {
                    text: '一周前',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', date);
                    }
                }, {
                    text: '30天前',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 30);
                        picker.$emit('pick', date);
                    }
                }
                    , {
                        text: '90天前',
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', date);
                        }
                    }]
            },
            checkedAll: false,
            filterValue: ['需要'],
            checkedNeed: true,
            remark: '',
            selectedPlans: [],
            nextTimeTips: '2024-11-11 11:22:22',
            logSearchForm: {
                startTime: formatCurrentTime(),
                endTime: formatCurrentTime(),
                // module:''
            },
            addLogForm: { module: '', parts: '', content: '', maintenance_id: 1 },
            addLogTableData: [
                // {
                //         "parts":"部件",
                //     "content": "保养内容",
                //     "way" :  "保养方法",
                //     "standard" :  "保养标准",
                //     "period" :  "保养周期",

                //      },
                //      {
                //         "parts":"部件1",
                //     "content": "保养内容1",
                //     "way" :  "保养方法1",
                //     "standard" :  "保养标准1",
                //     "period" :  "保养周期1",

                //      }
            ],
            selectedModule: '',
            selectedModuleSearch: '',
            modules: [{

                module: "模块1",
                children: [{
                    parts: "部件",
                    way: "保养方法",
                    standard: "保养标准",
                    info: '222222',
                    period: '1'
                }]
            }, {

                module: "模块2",
                children: [{
                    parts: "部件2",
                    way: "保养方法22",
                    standard: "保养标准2",
                    info: '1111',
                    period: '2'
                }]
            }

            ],

            okNgData: [{ parts: 'bujian', way: 'fangfa', standard: 'biaozhun' },
                { parts: 'bujian11', way: 'fangfa11', standard: 'biaozhun11', opt: "NG" }
            ],
            optionsmodule: [{ label: "模块1", value: "模块1" }],
            optionsParts: [{ label: "bujian1", value: "bujian1" }],
            optionsContent: [{ label: "保养内容", value: "保养内容" }],
            selectedmodule: '',
            selectedParts: '',
            selectedContent: '',
            is_showAddLog: false,
            tableDataLog: [
                // {
                //     "id": 888,
                //     "module": 457111111,
                //     "parts": "部件",
                //     "content": "1",
                //     "way": "1", //保养方法
                //     "standard": "ddf",
                //     "period": "每日" //保养周期
                // }

            ],
            planCurrentRow: null,
            qtCall: null,
            activeName: 'first',
            tableDataSchedule: [

            ],
            tableDataScheduleFilter: [],
            is_showAddPlan: false,
            addPlanForm: {
                maintenance_id: 1,
                label: '',
                type: '',
                dateTime: formatCurrentTime(),
                nextTime: formatCurrentTime(),
                operation: ''
            },
            adddata: [{

                "module": "模块",
                "children": [{
                    "parts": "部件",
                    "content": "保养内容",
                    "way": "保养方法",
                    "standard": "保养标准",
                    "period": "保养周期",

                }, ]
            },
                {

                    "module": "模块1",
                    "children": [{
                        "parts": "部件1",
                        "content": "保养内容1",
                        "way": "保养方法1",
                        "standard": "保养标准1",
                        "period": "保养周期1",

                    }, ]
                }
            ]
        }
    },
    mounted() {
        if (process.env.NODE_ENV != 'production') {
            this.tableDataLog = [{
                "id": '888',

                "operateUser": "457111111",

                "content": "1",

                "dateTime": "2021-11-11 11:33:33"
            },
                {
                    "id": '888',

                    "operateUser": "457111111",

                    "content": "1",

                    "dateTime": "2021-11-11 11:33:33"

                }

            ]
            this.tableDataSchedule = [{
                maintenance_id: "457111111",
                station: "工站",
                parts: "部件",
                content: "保养内容",
                way: "方法",
                standard: "标准",
                period: "周期",
                preDatetime: "2024-11-11",
                needMaintenance: "需要", //本次是否需要保养  '需要, 不需要'
                checked: false
            },
                {
                    "maintenance_id": "3344",
                    "station": "工站1",
                    "parts": "部件1",
                    "content": "保养内容1",
                    "way": "方法1",
                    "standard": "标准",
                    "period": "周期",
                    "preDatetime": "上次保养时间",
                    "needMaintenance": "不需要", //本次是否需要保养  '需要, 不需要'
                    "checked": false

                }
            ]

            for (let index = 0; index < 17; index++) {
                var tmps = { ...this.tableDataSchedule[0] }
                console.log(999, tmps)
                tmps['maintenance_id'] = index
                this.tableDataSchedule.push(tmps)
                this.tableDataScheduleFilter = this.tableDataSchedule.filter(item => item.needMaintenance == '需要')
                this.tableDataLog.push(this.tableDataLog[0])
            }
            for (let index = 0; index < 22; index++) {
                this.okNgData.push({ parts: 'bujian', way: 'fangfa', standard: 'biaozhun' })

            }

        }

        if (process.env.NODE_ENV === 'production') {
            // new qwebchannel.QWebChannel(qt.webChannelTransport, (channel) => {
            // this.qtCall = channel.objects.webBridge;
            this.qtCall = this.$qtCall
            this.qtCall.QtToJs.connect((func, json) => {
                // console.log('connect-func', func)
                // console.log('connect-func-json', json)
                if (func == 'RefreshMaintenancePlansNew') {
                    var datas = JSON.parse(json)
                    if (datas.code === 200) {
                        this.tableDataSchedule = []
                        this.tableDataScheduleFilter = []
                        console.log('获取保养计划数据', datas.data)
                        datas.data['MaintenancePlans'].forEach(item => {
                            this.tableDataSchedule.push({ ...item, checked: false })
                            if (item.needMaintenance == '需要') {
                                this.tableDataScheduleFilter.push({ ...item, checked: false })
                            }
                        })
                        // this.tableDataScheduleFilter = this.tableDataSchedule.filter(item=> item.needMaintenance=='需要')
                        this.nextTimeTips = datas.data['NextTime']
                    }
                }
                if (func == 'RefreshMaintenanceLogsNew') {
                    var datas = JSON.parse(json)
                    if (datas.code === 200) {
                        console.log('获取保养记录数据', datas.data)
                        this.tableDataLog = datas.data['MaintenanceLogs']
                    }
                }
                if (func == 'NeedAddMaintenanceLogList') {
                    var datas = JSON.parse(json)
                    if (datas.code === 200) {
                        console.log('获取保养记录添加列表数据', datas.data)
                        this.adddata = datas.data['AddData']
                        this.optionsContent = []
                        this.optionsParts = []
                        this.optionsmodule = []
                        this.adddata.forEach(item => {
                            this.optionsmodule.push({ label: item.module, value: item.module })
                        });

                    }

                }
                if (func == 'AddMaintenanceLogLinkageList') {
                    var datas = JSON.parse(json)
                    if (datas.code === 200) {
                        console.log('获取保养记录添加二级列表数据', datas.data)
                        this.adddata = datas.data['AddData']
                        this.addLogTableData = []
                        this.adddata.forEach(item => {
                            this.addLogTableData.push(item)
                        });

                    }

                }
                if (func == 'AddMaintenancePlanLinkageList') {
                    var datas = JSON.parse(json)
                    if (datas.code === 200) {
                        console.log('保养计划-刷新模块-部件联动', datas.data)
                        console.log('test', '先不赋值')
                        this.modules = []
                        datas.data['AddData'].forEach(item => {
                            this.modules.push({ ...item, opt: 'OK' })
                        })
                        console.log('this.modules', this.modules)
                        console.log('test', '测试日志')
                    }
                }
            })
            this.qtCall.JsToQt("RefreshMaintenanceLogsNew", {});
            this.qtCall.JsToQt("RefreshMaintenancePlansNew", {});
            this.qtCall.JsToQt("AddMaintenancePlanLinkageList", {});
            // })
        }
        if (process.env.NODE_ENV === 'production') {
            // this.qtCall.JsToQt('NeedAddMaintenanceLogList',{})

            this.qtCall.JsToQt('AddMaintenanceLogLinkageList', {})
        }
    },
    methods: {
        tableRowClassName({ row, rowIndex }) {
            console.log('tableRowClassName', row)
            // if (row.needMaintenance == '需要') {
            //     return 'warning-row'
            // } else {
            //     return 'default'
            // }
        },
        checkAll() {
            if (this.checkedAll) {
                this.tableDataScheduleFilter.forEach(item => {
                    item.checked = true
                })
            } else {
                this.tableDataScheduleFilter.forEach(item => {
                    item.checked = false
                })
            }
        },
        checkNeed() {
            console.log('仅显示需要?', this.checkedNeed)
            if (this.checkedNeed == true) {
                this.tableDataScheduleFilter = this.tableDataSchedule.filter(item => item.needMaintenance == '需要')
            } else {
                this.tableDataScheduleFilter = this.tableDataSchedule.filter(item => true)
            }
        },
        exportLog() {

            this.qtCall.JsToQt('ExportMaintenanceLog', this.logSearchForm)
        },
        savePlans() {

            var ids = []
            for (let index = 0; index < this.selectedPlans.length; index++) {
                const element = this.selectedPlans[index];
                ids.push(element['maintenance_id'])
            }
            // for (let index = 0; index < this.tableDataScheduleFilter.length; index++) {
            //     const element = this.tableDataScheduleFilter[index];
            //     ids.push(element['maintenance_id'])
            // }
            var params = { maintenance_id: ids, remark: this.remark, username: this.userInfoStore.userName }
            console.log(' 提交保养计划传参', params)
            if (process.env.NODE_ENV == 'production') {

                this.qtCall.JsToQt('AddMaintenancePlan', params)
            }
            this.is_showAddPlan = false//关闭弹窗
        },
        addPlans() {
            this.selectedPlans = []
            for (let index = 0; index < this.tableDataScheduleFilter.length; index++) {
                const element = this.tableDataScheduleFilter[index];
                if (element.checked == true) {
                    this.selectedPlans.push(element)
                }
            }
            if (this.selectedPlans.length == 0) {
                this.$alert("请勾选表格数据后操作", "提示")
                return
            }
            console.log('已勾选表格数据', this.selectedPlans)
            this.is_showAddPlan = true
            this.checkedAll = false;
        },
        selectPlans(selection) {
            this.selectedPlans = selection
        },
        searchLog() {
            const startTime = this.logSearchForm.startTime.split(" ")[0]
            this.logSearchForm.startTime = startTime
            const endTime = this.logSearchForm.endTime.split(" ")[0]
            this.logSearchForm.endTime = endTime
            console.log('RefreshMaintenanceLogsNew传参数‘', this.logSearchForm)
            this.qtCall.JsToQt("RefreshMaintenanceLogsNew", this.logSearchForm);
        },
        changeModule(val) {
            console.log('change-module', val)
            this.modules.forEach(item => {
                var children = item['children']
                if (item['module'] == val) {
                    console.log('module-children', children)
                    this.okNgData = []
                    children.forEach(child => {
                        this.okNgData.push({ ...child, opt: 'OK' })
                    })
                    console.log('联动部件列表', this.okNgData)
                }

            })
            this.$refs.addTable.setCurrentRow(this.okNgData[0])
        },
        selectLogTable(row) {
            var currentRow = row
            var way = currentRow.way
            var standard = currentRow.standard
            var parts = currentRow.parts
            var content = currentRow.content
            var period = currentRow.period
            this.addLogForm.content = content
            this.addLogForm.parts = parts
            this.addLogForm.module = this.selectedmodule
            if (currentRow.maintenance_id != null) {
                this.addLogForm.maintenance_id = currentRow.maintenance_id
            }

        },
        selectOkNg(selection) {

            console.log('selectokng', selection)
            var currentRow = selection
            var way = currentRow.way
            var standard = currentRow.standard
            var parts = currentRow.parts
            if (currentRow.maintenance_id != null) {
                this.addPlanForm.maintenance_id = currentRow.maintenance_id
            }

            this.addPlanForm.label = '模块:' + this.selectedModule + '  部件:' + parts + "  标准:" + standard + "  方法:" + way
        },
        showAddPlan() {
            this.is_showAddPlan = true
            this.qtCall.JsToQt("AddMaintenancePlanLinkageList", {});
        },
        addSaveLog() {
            // var param = {module:this.selectedmodule,parts:this.selectedParts,content:this.selectedContent}
            console.log('保养计划添加传参', this.addLogForm)
            this.qtCall.JsToQt("NeedAddMaintenanceLog", this.addLogForm);
            this.is_showAddLog = false
        },
        changemodule(val) {
            console.log('选中模块', val)
            // this.adddata.forEach(item=>{
            //     if(item['module']==val){
            //         var parts = item['children']
            //         parts.forEach(pitem=>{
            //             this.optionsParts.push({label:pitem['parts'],value:pitem['parts'],children:pitem['children']})
            //         })
            //     }
            // })
            this.addLogTableData = []
            this.adddata.forEach(item => {
                console.log(item['module'])
                if (item['module'] == val) {
                    console.log(item)
                    var pitem = item['children']
                    this.addLogTableData = pitem
                }

            })
            this.$refs.addTableLog.setCurrentRow(this.addLogTableData[0])
            selectLogTable(this.addLogTableData[0])
        },
        changeParts(val) {
            console.log('选中部件', val)
            console.log('部件数组', this.optionsParts)

            this.optionsParts.forEach(item => {
                if (item['value'] == val) {
                    var content = item['children']
                    content.forEach(pitem => {
                        this.optionsContent.push({ label: pitem['content'], value: pitem['content'] })
                    })
                }
            })
        },
        showAddLog() {
            // this.userStoreLimits.testuser = '1'
            // this.$store.dispatch('saveUserStoreLimits', {testuser: 111})
            // console.log('storeuser',this.userStoreLimits )
            this.is_showAddLog = true

        },
        addSavePlan() {
            console.log('保养计划添加传参', this.addPlanForm)
            this.qtCall.JsToQt("NeedAddMaintenancePlan", this.addPlanForm);
            this.is_showAddPlan = false
            this.is_showAddPlan1 = false
        },
        deletePlan() {
            console.log('保养计划选中行-删除', this.planCurrentRow)
            if (this.planCurrentRow == null) {
                this.$alert('请选择一行数据操作', '提示')
                return
            }
            this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                var param = { id: this.planCurrentRow.id }
                console.log('保养计划选中行-删除传参', param)
                this.qtCall.JsToQt("NeedDeleteMaintenancePlan", param);
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });

        },
        planRowClick(row, column, event) {
            this.planCurrentRow = row
        }
    }

}
</script>

<style scoped>
/deep/ .el-button-group i {
    font-weight: 600;
    font-size: large;
}

/deep/ .el-table .warning-row {
    background: rgb(239, 132, 132);
}
</style>
